﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Pow.components
{
	
	class MenuButton : DrawableGameComponent
	{

		Game1 game;
		Texture2D hoverBullet;
		SpriteFont font;
		Vector2 position;
		String label;
        public int frame;
        public int counter = 0;

		public MenuButton(Game game, String label, Vector2 position) : base(game)
		{
			this.game = game as Game1;
			this.label = label;
			this.position = position;
			LoadContent();
		}

		protected override void LoadContent()
		{
			hoverBullet = game.Content.Load<Texture2D>("Naves-1");
			//hoverBullet = hoverBullet.Height / 2;
			font = game.Content.Load<SpriteFont>("SpriteFont1");
		}

		public override void Update(GameTime gameTime)
		{
           

            base.Update(gameTime);
		}

		Boolean selected;
		public void select() {
			selected = true;
		}
		public void deselect() {
			selected = false;
		}


		public override void Draw(GameTime gameTime)
		{
            // Animação da nave
            counter++;
            frame = (counter / 10) + 2;
            if (counter >= 19)
                counter = 0;

			game.spriteBatch.Begin();
			if(selected)
				//game.spriteBatch.Draw(hoverBullet, position, Color.White);
                game.spriteBatch.Draw(hoverBullet, new Vector2 (position.X - 50, position.Y - 10), new Rectangle(140 * frame, 0, 140, 140), Color.White, 0f, Vector2.Zero, .3f, SpriteEffects.None, 0);
			game.spriteBatch.DrawString(font, label, position, Color.White);
			game.spriteBatch.End();
			base.Draw(gameTime);
		}
	}
}
